package com.example.demo.controller;

import com.example.demo.Entity.Product;
import com.example.demo.Repository.ProductRepository;
import com.example.demo.contants.DeleteFlag;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.util.List;

@RestController
@RequestMapping
public class Home {
    @Autowired
    private ProductRepository productRepository;

    @RequestMapping("/hi")
    public String hi() throws JsonProcessingException {
        Product product = new Product();
        product.setProductName("可乐");
        product.setDelFlag(DeleteFlag.NO);
        product.setCreateTime(LocalDateTime.now());
        productRepository.save(product);
        List<Product> honey = productRepository.findAll();
        honey.stream().forEach(System.out::println);

        return "hey!";
    }
}
